﻿using System;
using System.Web.UI;

using Sunyi.Project.WebPoint.BusinessLogic;
using Sunyi.Project.WebPoint.Common;
using Sunyi.Project.WebPoint.DataContract;
using Sunyi.Project.WebPoint.WebControl;

namespace ActivitySystem.Web.Admin
{
    public partial class AuditLogDetail : WebPointPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                try
                {
                    if (!string.IsNullOrEmpty(Request.Params[WebPointGlobalConstant.AuditLogId]))
                    {
                        Guid auditLogId = new Guid(Request.Params[WebPointGlobalConstant.AuditLogId]);
                        BindAuditLog(auditLogId);
                    }
                }
                catch (Exception ex)
                {
                    ExceptionHandler.Handle(this, ex);
                }
            }
        }

        #region Private Method

        private void BindAuditLog(Guid auditLogId)
        {
            AuditLog auditLog = AuditLogger.Select(auditLogId);

            if (auditLog != null)
            {
                tbxId.Text = auditLog.Id.ToString();
                tbxOperationCode.Text = auditLog.OperationCode;
                tbxSource.Text = auditLog.Source;
                tbxCategory.Text = auditLog.Category;
                tbxUserName.Text = auditLog.UserName;
                tbxInsertTimestamp.Text = auditLog.InsertTimestamp.ToString();
                tbxData.Text = auditLog.Data;
            }
        }

        #endregion
    }
}